package com.strategy2;

import com.strategy.Strategy;
import com.strategy.impl.ConcretStrategyA;
import com.strategy.impl.ConcretStrategyB;
import com.strategy.impl.ConcretStrategyC;

/**
 * 策略类与简单工厂相结合
 * 
 * @author Administrator
 * 
 */
public class Context {

	public Strategy strategy;

	public Context(char type) {
		switch (type) {
		case 'A':
			this.strategy = new ConcretStrategyA();
			break;
		case 'B':
			this.strategy = new ConcretStrategyB();
			break;
		case 'C':
			this.strategy = new ConcretStrategyC();
			break;
		}
	}

	// 根据具体的策略对象，调用其算法的方法
	public void contextInterface(int i) {
		strategy.getSum(i);
	}

}
